-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reset neuron data on registration #522
reset neuron data on registration #522
Conversation
@distributedstatemachine I don't think I'm doing any math operations |
Apologies @andreea-popescu-reef , i meant unsafe , or potentially panicing operation. @keithtensor can you take a look ? the CI should catch these |
56a0328
to
4e4af9d
Compare
pallets/subtensor/src/uids.rs
Outdated
@@ -9,6 +9,22 @@ impl<T: Config> Pallet<T> { | |||
SubnetworkN::<T>::get(netuid) | |||
} | |||
|
|||
pub fn set_emission_for_uid(netuid: u16, neuron_uid: u16, emission: u64) { | |||
Emission::<T>::mutate(netuid, |v| v[neuron_uid as usize] = emission); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this direct indexing panic? cc @keithtensor
4e4af9d
to
85895a4
Compare
85895a4
to
44ce566
Compare
pallets/subtensor/src/uids.rs
Outdated
@@ -9,6 +9,15 @@ impl<T: Config> Pallet<T> { | |||
SubnetworkN::<T>::get(netuid) | |||
} | |||
|
|||
/// Resets the trust, emission, consensus, incentive, dividends of the neuron to default | |||
pub fn clear_neuron(netuid: u16, neuron_uid: u16) { | |||
Emission::<T>::mutate(netuid, |v| v[neuron_uid as usize] = 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the length check before index with neuron_uid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
232f687
to
51fc171
Compare
@@ -9,6 +9,26 @@ impl<T: Config> Pallet<T> { | |||
SubnetworkN::<T>::get(netuid) | |||
} | |||
|
|||
fn clear_element_at<N>(position: u16) -> impl Fn(&mut Vec<N>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are almost there! can you please add doc comments to this , as it would break some lints down the line.
I will get this approved today , and move it through our deployment process. I estimate this change would be on testnet in about 2 weeks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, added.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@distributedstatemachine could you take a look at this again?
Description
On neuron registration the trust, emission, consensus, incentive, dividends values as well as axon info associated with the assigned neuron_uid are inherited from the previous neuron. Thus for the first few blocks after registration these values will be wrong, then reset to zero and then get populated with the correct values for the newly registered neuron. This change resets these values on neuron registration.
Related Issue(s)
N/A
Type of Change
Breaking Change
no
Checklist
cargo fmt
andcargo clippy
to ensure my code is formatted and linted correctlyScreenshots (if applicable)
N/A
Additional Notes
N/A